package cn.muqingfeng.util;

import android.graphics.Bitmap;
import android.graphics.Matrix;

public class BitmapUtil {

	public static Bitmap scaleTo(Bitmap bitmap, int w, int h) {
		int bmpWidth = bitmap.getWidth();
		int bmpHeight = bitmap.getHeight();

		float scaleWidth = (float) w / bmpWidth;
		float scaleHeight = (float) h / bmpHeight;

		Matrix matrix = new Matrix();
		matrix.postScale(scaleWidth, scaleHeight);

		Bitmap resizeBitmap = Bitmap.createBitmap(bitmap, 0, 0, bmpWidth, bmpHeight, matrix, false);
		bitmap.recycle();
		return resizeBitmap;
	}
}
